#include "calculator_ui.h"
#include "math_lib.h"
#include <iostream>
#include <iomanip>

CalculatorUI::CalculatorUI() {
    // 构造函数
}

CalculatorUI::~CalculatorUI() {
    // 析构函数
}

void CalculatorUI::demonstrateBasicCalculations() {
    using namespace MathLib;
    
    double a = 15.5;
    double b = 4.2;
    
    std::cout << std::fixed << std::setprecision(2);
    std::cout << "基本计算 (a=" << a << ", b=" << b << "):" << std::endl;
    std::cout << "  加法: " << a << " + " << b << " = " << Calculator::add(a, b) << std::endl;
    std::cout << "  减法: " << a << " - " << b << " = " << Calculator::subtract(a, b) << std::endl;
    std::cout << "  乘法: " << a << " * " << b << " = " << Calculator::multiply(a, b) << std::endl;
    std::cout << "  除法: " << a << " / " << b << " = " << Calculator::divide(a, b) << std::endl;
    std::cout << "  幂运算: " << a << " ^ " << b << " = " << Calculator::power(a, b) << std::endl;
}

void CalculatorUI::demonstrateGeometryCalculations() {
    using namespace MathLib;
    
    double radius = 5.0;
    double width = 8.0;
    double height = 6.0;
    
    std::cout << std::fixed << std::setprecision(2);
    std::cout << "几何计算:" << std::endl;
    std::cout << "  圆面积 (半径=" << radius << "): " << Geometry::circleArea(radius) << std::endl;
    std::cout << "  矩形面积 (宽=" << width << ", 高=" << height << "): " << Geometry::rectangleArea(width, height) << std::endl;
    std::cout << "  三角形面积 (底=" << width << ", 高=" << height << "): " << Geometry::triangleArea(width, height) << std::endl;
    std::cout << "  球体积 (半径=" << radius << "): " << Geometry::sphereVolume(radius) << std::endl;
}

void CalculatorUI::demonstrateStatisticsCalculations(const std::vector<double>& data) {
    using namespace MathLib;
    
    std::cout << std::fixed << std::setprecision(2);
    std::cout << "统计计算 (数据集: ";
    for (size_t i = 0; i < data.size(); ++i) {
        std::cout << data[i];
        if (i < data.size() - 1) std::cout << ", ";
    }
    std::cout << "):" << std::endl;
    
    std::cout << "  平均值: " << Statistics::mean(data) << std::endl;
    std::cout << "  中位数: " << Statistics::median(data) << std::endl;
    std::cout << "  方差: " << Statistics::variance(data) << std::endl;
    std::cout << "  标准差: " << Statistics::standardDeviation(data) << std::endl;
}

void CalculatorUI::printSeparator() {
    std::cout << "----------------------------------------" << std::endl;
}